home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / misc / digivfo / dds.a86 < prev    next >
Text File  |  1995-03-23  |  46KB  |  1,498 lines

  1. ;--------------------------------------------
  2. ;       Harris 45102 DDS routines.          -
  3. ;       Dover Research Corporation          -
  4. ;       November 2nd 1993, Feb 19th 1995    -
  5. ;       All rights reserved                 -
  6. ;                                           -
  7. ; Author: James J. Craswell WB0VNE/AAV5TH   -
  8. ; Part of a commercial product so this code -
  9. ;         Is NOT Public Domain              -
  10. ;            (612) 492-3913                 -
  11. ;--------------------------------------------
  12. ; BUGS:                                     -
  13. ; Display still does not work properly if   -
  14. ; you operate outside of the 1 MHz range.   -
  15. ;--------------------------------------------
  16.   
  17. data    segment
  18.  
  19. org     08000h
  20.  
  21. io_count dw     0               ; 0 = non-intialized count
  22. io_flag  db     0               ; bit 7=1 at end of 5mS wait
  23.  
  24.  
  25. msb     dw      ?               ;Storage place for data
  26. lsb     dw      ?               ;Bottom word for data.
  27.          
  28. msb1    dw      ?               ;temp location for add/sub.
  29. lsb1    dw      ?               
  30.  
  31. msb2    dw      ?               ;temp location for step hold area.               
  32. lsb2    dw      ?
  33.  
  34. msb3    dw      ?               ;Temp location for comparisons.
  35. lsb3    dw      ?
  36.  
  37. msb4    dw      ?
  38. lsb4    dw      ? 
  39.  
  40. msb5    dw      ?
  41. lsb5    dw      ?
  42.                 ;32Bit Divide stuff.
  43. dvmsb   dw      ?               ;Dividend.
  44. dvlsb   dw      ?               ;The number to be divided.
  45. dmsb    dw      ?               ;Divisor.
  46. dlsb    dw      ?
  47. rmsb    dw      ?               ;Remainder
  48. rlsb    dw      ?               
  49. amsb    dw      ?               ;32Bit answer.
  50. alsb    dw      ?               
  51.           
  52.  
  53. msbf1   dw      ?
  54. lsbf1   dw      ?
  55.  
  56. msbf2   dw      ?
  57. lsbf2   dw      ?
  58.  
  59. msbf3   dw      ?
  60. lsbf3   dw      ?
  61.  
  62. msbf4   dw      ?
  63. lsbf4   dw      ?
  64.  
  65. msbf5   dw      ?
  66. lsbf5   dw      ?
  67.  
  68. msbf6   dw      ?
  69. lsbf6   dw      ? 
  70.  
  71. msbf7   dw      ?
  72. lsbf7   dw      ?
  73.  
  74. msbf8   dw      ?
  75. lsbf8   dw      ?
  76.  
  77. msbf9   dw      ?
  78. lsbf9   dw      ?
  79.  
  80. msbf10  dw      ?
  81. lsbf10  dw      ?
  82.  
  83. msbs    dw      ?                       ;Step locations.
  84. lsbs    dw      ?
  85.  
  86. mode    db      ?                       ;Mode For step up/down program.
  87.                     ;0 = 0.1 / 0.009
  88.                     ;1 = 1 / 0.1
  89.                     ;2 = 10 / 1
  90.                     ;3 = 100 / 10
  91.                     ;4 = 1KHz / 100
  92.                     ;5 = 10KHz / 1KHz
  93.                     ;6 = 100KHz / 10KHz
  94.                     ;7 = 1MHz / 100KHz
  95.  
  96.  
  97. ;------------------
  98. ; VFO START RANGE -
  99. ;------------------
  100. ;vfomsb  equ     2051h                  ;MSB - TR7A.
  101. ;vfolsb  equ     0efffh                 ;LSB - 5.05 to 5.55 MHz
  102. vfomsb  equ     2333h                   ;MSB - KENWOOD TS130. 
  103. vfolsb  equ     3053h                   ;LSB - 5.5 MHz to 6.0 MHz
  104. ;vfomsb  equ     7599h                  ;msb to set VFO to 140MHz.
  105. ;vfolsb  equ     7bd2h                  ;lsb to set VFO to 140MHz.
  106.  
  107.  
  108. ;--------------------------------------------
  109. ; All numbers based on the assumption that...
  110. ; 1 = .009313588 HRz steps
  111. ;--------------------------------------------
  112. h001    equ     1h                      ;0.009 Hertz steps.
  113. h01     equ     0ah                     ;0.1 Hertz steps.
  114. h1      equ     6bh                     ;1 Hertz steps.
  115. h10     equ     431h                    ;10 Hertz stepss.
  116. h100    equ     29f1h                   ;100 Hertz steps.
  117. h1kl    equ     0a36ah                  ;lsb 1KHz steps.
  118. h1km    equ     1h                      ;msb 1KHz steps.
  119. h10kl   equ     6224h                   ;lsb 10KHz steps.
  120. h10km   equ     10h                     ;msb 10KHz steps.
  121. h100kl  equ     0d568h                  ;lsb 100KHz steps.
  122. h100km  equ     0a3h                    ;msb 100KHz steps.
  123. h1ml    equ     6516h                   ;lsb 1Mhz steps.
  124. h1mm    equ     666h                    ;msb 1MHz steps.
  125.  
  126. esc     equ     01h                     ;Escape scan code
  127. who     equ     35h                     ;? character.
  128. shhome  equ     4700h
  129. home    equ     4737h
  130. shend   equ     4f00h
  131. endkey  equ     4f31h
  132. shup    equ     4838h                   ;Shift up arrow.
  133. shdn    equ     5032h                   ;Shift down arrow.
  134. upar    equ     4800h                   ;Up arrow.
  135. dnar    equ     5000h                   ;down arrow.
  136. akey    equ     1eh                     ;a key.
  137. bkey    equ     30h                     ;b key.
  138. ckey    equ     2eh                     ;c key.
  139. dkey    equ     20h                     ;d key.
  140. fkey    equ     21h                     ;f key.
  141. pkey    equ     19h                     ;p key.
  142. rkey    equ     13h                     ;r key.
  143. skey    equ     1fh                     ;s key.
  144. pgdn    equ     51h                     ;Page Down key.
  145. pgup    equ     49h                     ;Page up key.
  146. pluskey equ     4eh                     ;Plus key.
  147. minkey  equ     4ah                     ;Minus key.
  148. f1key   equ     3bh                     ;Function keys
  149. f2key   equ     3ch
  150. f3key   equ     3dh
  151. f4key   equ     3eh
  152. f5key   equ     3fh
  153. f6key   equ     40h
  154. f7key   equ     41h
  155. f8key   equ     42h
  156. f9key   equ     43h
  157. f10key  equ     44h
  158.  
  159. lcnt    equ     32                      ;How many bits to shift.
  160.  
  161. ;ioport  equ     3bch                    ;Compaq portable port (also LPT1:)
  162. ioport  equ     278h                   ;Address of PCOSITIVE printer port.
  163. ;ioport  equ     378h                   ;Address of the other printer port
  164.  
  165. idle    equ     0b4h                    ;Sets the machine to the idle state.  
  166. xfer    equ     0fbh                    ;and mask to turn off 4 bit - 32b clk to dds.
  167. dat1    equ     2                       ;Set the data bit off.
  168. clk     equ     1                       ;Clock a data bit in.
  169.  
  170. stepm   equ     0h                      ;msb for step.
  171. stepl   equ     431h                    ;1 = 0.009HRz step.
  172.  
  173. val     db      ?                       ;One byte storage.
  174.  
  175. data    ends
  176.  
  177. ;-----------------------------------
  178.  
  179. code    segment
  180.  
  181. Start:  call    cls                     ;clear screen
  182.     mov     dx,OFFSET msg           ;Load banner msg
  183.     call    print                   ;Print the advert to the screen.
  184.     mov     dx,OFFSET msg0
  185.     call    print
  186.     mov     (lsb1),h1kl
  187.     mov     (msb1),h1km
  188.     mov     (lsb2),h10kl
  189.     mov     (msb2),h10km
  190.     mov     (mode),5
  191.     mov     msbf1,vfomsb    ;Initialize all memory channels to zero.
  192.     mov     lsbf1,vfolsb    ;New version will load these from a disk file.
  193.     mov     msbf2,msbf1 
  194.     mov     lsbf2,lsbf1
  195.     mov     msbf3,msbf1
  196.     mov     lsbf3,lsbf1
  197.     mov     msbf4,msbf1
  198.     mov     lsbf4,lsbf1
  199.     mov     msbf5,msbf1
  200.     mov     lsbf5,lsbf1
  201.     mov     msbf6,msbf1
  202.     mov     lsbf6,lsbf1
  203.     mov     msbf7,msbf1
  204.     mov     lsbf7,lsbf1
  205.     mov     msbf8,msbf1
  206.     mov     lsbf8,lsbf1
  207.     mov     msbf9,msbf1
  208.     mov     lsbf9,lsbf1
  209.     mov     msbf10,msbf1
  210.     mov     lsbf10,lsbf1
  211.  
  212.     call    idleit          ;Start DDS in idle mode.
  213.  
  214. init:   mov     msb,vfomsb      ;Store start freq MSB.
  215.     mov     lsb,vfolsb      ;Store start freq lsb.
  216.     call    loadit
  217.     call    loadit          ;Set DDS to zero freq.
  218. ;       mov     cx,lcnt         ;Load length of data to shift (32 bits).
  219. ;       mov     si,msb          ;Load msb
  220. ;       mov     di,lsb          ;Load lsb
  221. ;       call    wrtdat          ;Write data bit.
  222. ;       call    xferit          ;Signal transfer done.
  223. ;       call    idleit
  224.  
  225. keylp:  call    disfrq
  226.     call    keyin           ;Read a keystroke.
  227.  
  228. key3:   cmp     ax,upar         ;Up freq 1x?
  229.     jnz     key4
  230.     call    up1x
  231.     jmp     keylp
  232. key4:   cmp     ax,dnar         ;Down freq 1x?
  233.     jnz     key5
  234.     call    dn1x
  235.     jmp     keylp
  236. key5:   cmp     ax,shup         ;Bump freq up 10x?
  237.     jnz     key6
  238.     call    up10x
  239.     jmp     keylp
  240. key6:   cmp     ax,shdn         ;Bump freq down 10x?
  241.     jnz     key7
  242.     call    dn10x
  243.     jmp     keylp
  244. key7:   cmp     ah,pkey         ;Panadapter bandscanner key?
  245.     jnz     key8
  246.     call    sweep                              
  247.     jmp     keylp
  248. key8:   cmp     ah,who          ;?Copyright help info?
  249.     jnz     key9
  250.     call    copyr
  251.     jmp     keylp
  252. key9:   cmp     ah,skey         ;(S)ave a freq in a memory (F) key.
  253.     jnz     key10
  254.     call    savem           ;Save memory.
  255.     mov     dx,OFFSET msg11
  256.     call    print
  257.     jmp     keylp
  258. key10:  cmp     ah,esc          ;Is this an ESC key?
  259.     jnz     key11
  260.     jmp     endit           ;It is so end this program now.
  261. key11:  cmp     ah,rkey         ;Reset VFO to zero?
  262.     jnz     key12
  263.     jmp     init            ;restart program.
  264. key12:  cmp     ah,pluskey      ;Bump frequency steps up?
  265.     jnz     key13
  266.     call    bumpup
  267.     jmp     keylp
  268. key13:  cmp     ah,minkey       ;Bump frequency steps down?
  269.     jnz     key14
  270.     call    bumpdn
  271.     jmp     keylp
  272. key14:  cmp     ah,dkey         ;Direct frequency entry?
  273.     jnz     key15           ;Jump if not.
  274.     call    direct
  275.     jmp     keylp
  276. key15:  cmp     ah,f1key        ;Play back a memory key?
  277.     jnz     key16           ;Such as F1?
  278.     mov     msb,msbf1
  279.     mov     lsb,lsbf1
  280.     call    loadit
  281.     call    loadit
  282.     jmp     keylp
  283. key16:  cmp     ah,f2key        ;Play back F2?
  284.     jnz     key17
  285.     mov     msb,msbf2
  286.     mov     lsb,lsbf2
  287.     call    loadit
  288.     call    loadit
  289.     jmp     keylp
  290. key17:  cmp     ah,f3key        ;Play back F3?
  291.     jnz     key18
  292.     mov     msb,msbf3
  293.     mov     lsb,lsbf3
  294.     call    loadit
  295.     call    loadit
  296.     jmp     keylp
  297. key18:  cmp     ah,f4key        ;Play back F4?
  298.     jnz     key19
  299.     mov     msb,msbf4
  300.     mov     lsb,lsbf4
  301.     call    loadit
  302.     call    loadit
  303.     jmp     keylp
  304. key19:  cmp     ah,f5key        ;Play back F5?
  305.     jnz     key20
  306.     mov     msb,msbf5
  307.     mov     lsb,lsbf5
  308.     call    loadit
  309.     call    loadit
  310.     jmp     keylp
  311. key20:  cmp     ah,f6key        ;Play back F6?
  312.     jnz     key21
  313.     mov     msb,msbf6
  314.     mov     lsb,lsbf6
  315.     call    loadit
  316.     call    loadit
  317.     jmp     keylp
  318. key21:  cmp     ah,f7key        ;Play back F7?
  319.     jnz     key22
  320.     mov     msb,msbf7
  321.     mov     lsb,lsbf7
  322.     call    loadit
  323.     call    loadit
  324.     jmp     keylp
  325. key22:  cmp     ah,f8key        ;Play back F8?
  326.     jnz     key23
  327.     mov     msb,msbf8
  328.     mov     lsb,lsbf8
  329.     call    loadit
  330.     call    loadit
  331.     jmp     keylp
  332. key23:  cmp     ah,f9key        ;Play back F9?
  333.     jnz     key24
  334.     mov     msb,msbf9
  335.     mov     lsb,lsbf9
  336.     call    loadit
  337.     call    loadit
  338.     jmp     keylp
  339. key24:  cmp     ah,f10key       ;Play back F10?
  340.     jnz     key25
  341.     mov     msb,msbf10
  342.     mov     lsb,lsbf10
  343.     call    loadit
  344.     call    loadit
  345.     jmp     keylp
  346. key25:  cmp     ah,bkey         ;Band / Step setting for panadaptor?
  347.     jnz     key100
  348.     call    disfrq
  349.     jmp     keylp
  350. key100: call    beep
  351.     jmp     keylp
  352.  
  353.  
  354. ;--------------------------------
  355. ; Subroutines
  356. ;--------------------------------
  357.  
  358. ;---------------------------------------------
  359. ; END:  Return to PCDOS.
  360. ;---------------------------------------------
  361. endit:  mov     dx,OFFSET msg1  ;Load banner msg
  362.     call    print           ;Print the advert to the screen.
  363.     mov     ax,04c00        ;EXIT
  364.     int     33
  365.  
  366.  
  367. ;-----------------------------------------
  368. ; Step up (or down) 1x.
  369. ;-----------------------------------------
  370. up1x:   call    add32           ;Add it up.
  371.     call    loadit          ;Signal transfer done.
  372.     call    loadit
  373.     ret           
  374.  
  375. dn1x:   call    sub32           ;Subtract it.
  376.     call    loadit          ;Signal transfer done.
  377.     call    loadit
  378.     ret            
  379.  
  380. ;-----------------------------------------
  381. ; Step up (or down) 10x.           
  382. ; lsb1/msb1=1x values.
  383. ; lsb2/msb2=10x values.
  384. ; lsb3/msb3 scratch locations.
  385. ;-----------------------------------------
  386. up10x:  mov     (lsb3),(lsb1)   ;Save 1x values in xsb3.
  387.     mov     (msb3),(msb1)
  388.     mov     (lsb1),(lsb2)   ;Load 10x lsb steps.
  389.     mov     (msb1),(msb2)   ;Load 10x msb steps.
  390.     call    add32           ;Add it up.
  391.     call    loadit          ;Load the new freq into the DDS.
  392.     call    loadit
  393.     mov     (lsb1),(lsb3)   ;Restore 1x vlaues.
  394.     mov     (msb1),(msb3)        
  395.     ret                     ;Return.
  396.  
  397. dn10x:  mov     (lsb3),(lsb1)   ;Save 1x values in xsb3.
  398.     mov     (msb3),(msb1)
  399.     mov     (lsb1),(lsb2)   ;Load 10x lsb steps.
  400.     mov     (msb1),(msb2)   ;Load 10x msb steps.
  401.     call    sub32           ;Subtract from the current freq.
  402.     call    loadit          ;Load the new freq into the DDS.
  403.     call    loadit
  404.     mov     (lsb1),(lsb3)   ;Restore 1x vlaues.
  405.     mov     (msb1),(msb3)        
  406.     ret                     ;Return.
  407.  
  408. ;-----------------------------------------
  409. ; Save current freq to a memory key.    
  410. ;-----------------------------------------
  411. savem:  mov     dx,OFFSET savemsg
  412.     call    print
  413.     call    keyin           ;Read the keyboard.
  414. f1:     cmp     ah,f1key
  415.     jnz     f2
  416.     mov     msbf1,msb
  417.     mov     lsbf1,lsb
  418.     ret
  419. f2:     cmp     ah,f2key
  420.     jnz     f3
  421.     mov     msbf2,msb
  422.     mov     lsbf2,lsb
  423.     ret
  424. f3:     cmp     ah,f3key
  425.     jnz     f4
  426.     mov     msbf3,msb
  427.     mov     lsbf3,lsb
  428.     ret
  429. f4:     cmp     ah,f4key
  430.     jnz     f5
  431.     mov     msbf4,msb
  432.     mov     lsbf4,lsb
  433.     ret
  434. f5:     cmp     ah,f5key
  435.     jnz     f6
  436.     mov     msbf5,msb
  437.     mov     lsbf5,lsb
  438.     ret
  439. f6:     cmp     ah,f6key
  440.     jnz     f7
  441.     mov     msbf6,msb
  442.     mov     lsbf6,lsb
  443.     ret
  444. f7:     cmp     ah,f7key
  445.     jnz     f8
  446.     mov     msbf7,msb
  447.     mov     lsbf7,lsb
  448.     ret
  449. f8:     cmp     ah,f8key
  450.     jnz     f9
  451.     mov     msbf8,msb
  452.     mov     lsbf8,lsb
  453.     ret
  454. f9:     cmp     ah,f9key
  455.     jnz     f10
  456.     mov     msbf9,msb
  457.     mov     lsbf9,lsb
  458.     ret
  459. f10:    cmp     ah,f10key
  460.     jnz     bad
  461.     mov     msbf10,msb
  462.     mov     lsbf10,lsb
  463.     ret
  464. bad:    call    beep
  465.     mov     dx,OFFSET badkey
  466.     call    print
  467.     jmp     savem
  468.  
  469. ;-----------------------------------------
  470. ; Direct keyboard entry of the freq.
  471. ;-----------------------------------------
  472. direct: mov     dx,OFFSET msg12b
  473.     call    print           ;Clear the line.
  474.     mov     dx,OFFSET msg12 
  475.     call    print           ;Print the freq: xx. line
  476.     mov     cx,0
  477.     mov     msb3,msb1       ;Save original values.
  478.     mov     lsb3,lsb1
  479.     mov     msb1,h100km     ;Get 100 Khz digit into add/sub reg.
  480.     mov     lsb1,h100kl
  481.     mov     msb,vfomsb      ;Clear VFO to zero.
  482.     mov     lsb,vfolsb
  483.     call    getdig          ;Get first digit.
  484.     cmp     cx,0
  485.     jz      .nk1
  486. .m100:  call    add32
  487.     loop    .m100
  488. .nk1:   call    loadit          ;Load the new frequency
  489.     call    loadit
  490.     mov     cx,0            ;Restore original step.
  491.     mov     msb1,h10km
  492.     mov     lsb1,h10kl
  493.     call    getdig          ;Get a digit.
  494.     cmp     cx,0            ;Check for zero digit.
  495.     jz      .nk2            ;Zero so don't add anything.
  496. .m10:   call    add32
  497.     loop    .m10
  498. .nk2:   call    loadit
  499.     call    loadit
  500.     mov     cx,0
  501.     mov     cx,0            ;Restore original step.
  502.     mov     msb1,h1km
  503.     mov     lsb1,h1kl
  504.     call    getdig          ;Get a digit.
  505.     cmp     cx,0            ;Check for zero digit.
  506.     jz      .nk3            ;Zero so don't add anything.
  507. .m1:    call    add32
  508.     loop    .m1
  509. .nk3:   call    loadit
  510.     call    loadit
  511.     mov     dx,OFFSET mdot
  512.     call    print
  513.     mov     cx,0            ;Restore original step.
  514.     mov     msb1,0          ;No msb to add.
  515.     mov     lsb1,h100
  516.     call    getdig          ;Get a digit.
  517.     cmp     cx,0            ;Check for zero digit.
  518.     jz      .nk4            ;Zero so don't add anything.
  519. .m01:   call    add32
  520.     loop    .m01
  521. .nk4:   call    loadit
  522.     call    loadit
  523.     mov     cx,0
  524.     mov     cx,0            ;Restore original step.
  525.     mov     msb1,0          ;No msb to add.
  526.     mov     lsb1,h10
  527.     call    getdig          ;Get a digit.
  528.     cmp     cx,0            ;Check for zero digit.
  529.     jz      .nk5            ;Zero so don't add anything.
  530. .m001:  call    add32
  531.     loop    .m001
  532. .nk5:   call    loadit
  533.     call    loadit
  534.     mov     cx,0            ;Restore original step.
  535.     mov     msb1,0          ;No msb to add.
  536.     mov     lsb1,h1
  537.     call    getdig          ;Get a digit.
  538.     cmp     cx,0            ;Check for zero digit.
  539.     jz      .nk6            ;Zero so don't add anything.
  540. .m0001: call    add32
  541.     loop    .m0001
  542. .nk6:   mov     dx,OFFSET mdot
  543.     call    print
  544.     call    loadit
  545.     call    loadit
  546.     mov     cx,0            ;Restore original step.
  547.     mov     msb1,0          ;No msb to add.
  548.     mov     lsb1,h01 
  549.     call    getdig          ;Get a digit.
  550.     cmp     cx,0            ;Check for zero digit.
  551.     jz      .nk7            ;Zero so don't add anything.
  552. .m00001:call    add32
  553.     loop    .m00001
  554. .nk7:   call    loadit
  555.     call    loadit
  556.     mov     dx,OFFSET crlf
  557.     call    print
  558.     mov     msb1,msb3       ;Restore up down values.
  559.     mov     lsb1,lsb3
  560.     ret                     ;Return to main routine.
  561.  
  562. getdig: call    keyin
  563.     cmp     al,30h          ;0
  564.     jnz     .k1
  565.     mov     cx,0
  566.     mov     dx,OFFSET mn0
  567.     call    print
  568.     ret
  569.  
  570. .k1:    cmp     al,31h
  571.     jnz     .k2
  572.     mov     cx,1
  573.     mov     dx,OFFSET mn1
  574.     call    print
  575.     ret
  576.  
  577. .k2:    cmp     al,32h          ;2
  578.     jnz     .k3
  579.     mov     cx,2
  580.     mov     dx,OFFSET mn2
  581.     call    print
  582.     ret
  583.  
  584. .k3:    cmp     al,33h          ;3
  585.     jnz     .k4
  586.     mov     cx,3
  587.     mov     dx,OFFSET mn3
  588.     call    print
  589.     ret
  590.  
  591. .k4:    cmp     al,34h          ;4
  592.     jnz     .k5
  593.     mov     cx,4
  594.     mov     dx,OFFSET mn4
  595.     call    print
  596.     ret
  597.  
  598. .k5:    cmp     al,35h          ;5
  599.     jnz     .k6
  600.     mov     cx,5
  601.     mov     dx,OFFSET mn5
  602.     call    print
  603.     ret
  604.  
  605. .k6:    cmp     al,36h          ;6
  606.     jnz     .k7
  607.     mov     cx,6
  608.     mov     dx,OFFSET mn6
  609.     call    print
  610.     ret
  611.  
  612. .k7:    cmp     al,37h          ;7      
  613.     jnz     .k8
  614.     mov     cx,7
  615.     mov     dx,OFFSET mn7
  616.     call    print
  617.     ret
  618.  
  619. .k8:    cmp     al,38h          ;8
  620.     jnz     .k9
  621.     mov     cx,8
  622.     mov     dx,OFFSET mn8
  623.     call    print
  624.     ret
  625.  
  626. .k9:    cmp     al,39h          ;9
  627.     jnz     .kbad
  628.     mov     cx,9
  629.     mov     dx,OFFSET mn9
  630.     call    print
  631.     ret
  632.  
  633. .kbad:  call    beep 
  634.     jmp     getdig
  635.  
  636. ;-----------------------------------------
  637. ; Copyright message.
  638. ;-----------------------------------------
  639. copyr:  call    cls             ;Clear the screen.
  640.     mov     dx,OFFSET cmsg
  641.     call    print
  642.     mov     dx,OFFSET msg0
  643.     call    print
  644.     ret
  645.  
  646. ;-----------------------------------------
  647. ; Sweep a range.
  648. ;-----------------------------------------
  649. sweep:  mov     dx,OFFSET msg10
  650.     call    print
  651.     jmp     keylp           ;Forget it we arent done with panadaptor yet.
  652.  
  653.     mov     ax,stepl        ;Load our step frequency.
  654.     mov     bx,stepm
  655.     mov     (lsbs),ax       ;Move step freq into ax.
  656.     mov     (msbs),bx       ;Don't forget the msb!
  657.     mov     lsb1,ax         ;Put into...
  658.     mov     msb1,bx         ;Add subtract registers.
  659.  
  660. itnow:  call    add32           ;Add it up.
  661.     call    loadit          ;send new freq to the dds chip.
  662.     call    loadit
  663.     mov     ah,11h          ;Check for a keystroke.
  664.     int     16h
  665.     jz      itnow           ;No key so keep on sweeping.
  666.     jmp     endit
  667.     jmp     keylp           ;Got a key so process it.
  668.  
  669. bumpup: mov     al,(mode)       ;Read current mode.
  670.     cmp     al,7            ;Compare against max allowed value.
  671.     jz      enuf            ;Thats close enough!
  672.     inc     al              ;Else raise value.
  673.     mov     (mode),al       ;Save it for next time around.
  674.     cmp     al,1            ;Is it 1 / 0.1?
  675.     jz      m1
  676.     cmp     al,2            ;Is it 10 / 1?
  677.     jz      m2
  678.     cmp     al,3            ;Is it 100 / 10?
  679.     jz      m3
  680.     cmp     al,4            ;Is it 1KHz / 100?
  681.     jz      m4
  682.     cmp     al,5            ;Is it 10KHz / 1KHz?
  683.     jz      m5
  684.     cmp     al,6            ;Is it 100KHz / 10KHz?
  685.     jz      m6
  686.     cmp     al,7            ;Is it 1MHz / 100KHz?        
  687.     jz      m7
  688.     jmp     keylp
  689.  
  690. m0:     jmp     mode0
  691. m1:     jmp     mode1
  692. m2:     jmp     mode2
  693. m3:     jmp     mode3
  694. m4:     jmp     mode4
  695. m5:     jmp     mode5
  696. m6:     jmp     mode6
  697. m7:     jmp     mode7
  698.  
  699. ;-----------------------------------------
  700. ;Value already at max or minumum value.
  701. ;-----------------------------------------
  702. enuf:   call    beep            ;Warn operator.
  703.     jmp     keylp
  704.  
  705.  
  706. bumpdn: mov     al,(mode)       ;Read current mode.
  707.     cmp     al,0            ;Compare against minimum allowed value.
  708.     jz      enuf            ;Thats close enough!
  709.     dec     al              ;Else lower value.
  710.     mov     (mode),al       ;Save it for next time around.
  711.     cmp     al,0            ;Is it 0.1 / 0.009?
  712.     jz      m0
  713.     cmp     al,1            ;Is it 1 / 0.1?
  714.     jz      m1
  715.     cmp     al,2            ;Is it 10 / 1?
  716.     jz      m2
  717.     cmp     al,3            ;Is it 100 / 10?
  718.     jz      m3
  719.     cmp     al,4            ;Is it 1KHz / 100?
  720.     jz      m4
  721.     cmp     al,5            ;Is it 10KHz / 1KHz?
  722.     jz      m5
  723.     cmp     al,6            ;Is it 100KHz / 10KHz?
  724.     jz      m6
  725.     jmp     keylp           ;NOTE IT SHOULD BE IMPOSSABLE TO REACH THIS LOC.
  726.  
  727. mode0:  mov     dx,OFFSET msg2
  728.     call    print
  729.     mov     (lsb1),h001
  730.     mov     (msb1),0
  731.     mov     (lsb2),h01
  732.     mov     (msb2),0
  733.     ret
  734.  
  735. mode1:  mov     dx,OFFSET msg3
  736.     call    print
  737.     mov     (lsb1),h01
  738.     mov     (msb1),0
  739.     mov     (lsb2),h1
  740.     mov     (msb2),0
  741.     ret
  742.  
  743. mode2:  mov     dx,OFFSET msg4
  744.     call    print
  745.     mov     (lsb1),h1
  746.     mov     (msb1),0
  747.     mov     (lsb2),h10
  748.     mov     (msb2),0
  749.     ret
  750.  
  751. mode3:  mov     dx,OFFSET msg5
  752.     call    print
  753.     mov     (lsb1),h10
  754.     mov     (msb1),0
  755.     mov     (lsb2),h100
  756.     mov     (msb2),0
  757.     ret
  758.  
  759. mode4:  mov     dx,OFFSET msg6
  760.     call    print
  761.     mov     (lsb1),h100
  762.     mov     (msb1),0
  763.     mov     (lsb2),h1kl
  764.     mov     (msb2),h1km
  765.     ret
  766.  
  767. mode5:  mov     dx,OFFSET msg7
  768.     call    print
  769.     mov     (lsb1),h1kl
  770.     mov     (msb1),h1km
  771.     mov     (lsb2),h10kl
  772.     mov     (msb2),h10km
  773.     ret
  774.  
  775. mode6:  mov     dx,OFFSET msg8
  776.     call    print
  777.     mov     (lsb1),h10kl
  778.     mov     (msb1),h10km
  779.     mov     (lsb2),h100kl
  780.     mov     (msb2),h100km
  781.     ret
  782.  
  783. mode7:  mov     dx,OFFSET msg9
  784.     call    print
  785.     mov     (lsb1),h100kl
  786.     mov     (msb1),h100km
  787.     mov     (lsb2),h1ml
  788.     mov     (msb2),h1mm
  789.     ret
  790.  
  791. ;------------------------------------------
  792. ; PANADAPTOR SET
  793. ;------------------------------------------
  794. panset: call    beep
  795.     ret
  796.  
  797. ;------------------------------------------
  798. ; Loads the new frequency into the DDS.
  799. ;------------------------------------------
  800. loadit: 
  801.     mov     cx,lcnt         ;Load length of data to shift (32 bits).
  802.     mov     si,msb          ;Load msb
  803.     mov     di,lsb          ;Load lsb
  804.     call    wrtdat          ;Write data bit.
  805.     call    xferit          ;Signal transfer done.
  806. ;        push    dx
  807. ;        mov     dx,OFFSET msgli
  808. ;        call    print
  809. ;        pop     dx
  810.     ret
  811.  
  812. ;------------------------------------------
  813. ; WRITE DATA:
  814. ; MSB/LSB contain the 32 bit long word 
  815. ; that shall be written to the I/O port.
  816. ;------------------------------------------
  817. wrtdat: mov     ax,idle         ;Assume data bit is zero.
  818.     add     di,di           ;This routine will pop off the top bit in a 
  819.     adc     si,si           ;32 bit long word.
  820.     jc      da1             ;Data is equal to one.
  821. back:   call    outit           ;Write data to the I/O port.
  822.     or      al,clk          ;Turn on the clock bit.
  823.     call    outit           ;Clk in the valid data bit.
  824.     mov     al,idle         ;set data reg to idle.
  825.     call    outit           ;Idle the DDS chip.
  826.     dec     cx              ;sub 1 the count reg.
  827.     jnz     wrtdat          ;Loop til all 32 bits are sent out.
  828.     ret                     ;All 32 bits sent out so return.
  829. da1:    or      al,dat1         ;Set data bit on.     
  830.     jmp     back            ;Go back to routine.                     
  831.  
  832. ;---------------------------------------------
  833. ; IDLE:
  834. ; This routine sets the control lines to idle.
  835. ;---------------------------------------------
  836. idleit: mov     dx,ioport       ;Load the printer ports address.
  837.     mov     al,idle         ;Set al to idle.
  838.     call    outit           ;This sets the dds chip to idle.
  839.     ret                     ;And return.
  840.  
  841. ;---------------------------------------------
  842. ; TRANSFER:
  843. ; This routine signals the DDS that a 32 bit 
  844. ; command has been sent.
  845. ;---------------------------------------------
  846. xferit: mov     dx,ioport       ;Load the port address.
  847.     mov     ax,idle         ;Load al with idle.
  848.     and     al,xfer         ;Now Or in the xfer bit.
  849.     call    outit           ;DDS accepts 32bit data on rising edge of xfer.
  850.     mov     al,idle         ;Reload Idle.
  851.     call    outit           ;Write it to I/O port.
  852.     ret                     ;And return.
  853.  
  854. ;---------------------------------------------
  855. ; I/O PORT ROUTINE.                     
  856. ;---------------------------------------------
  857. outit:  out     dx,al
  858. ;       call    iodelay                 ;iodelay is a time hog forget this unless your
  859.                     ;machine won't work right.
  860.     ret
  861.  
  862. ;---------------------------------------------
  863. ; 32 Bit comparison.
  864. ; NOT FINISHED YET SO DON'T CALL THIS!!!
  865. ; If msb3/lsb3 is larger then carry=1 on return.
  866. ;---------------------------------------------
  867. comp32: push    ax                      ;Save so we can use as scratch.
  868.     push    bx                      ;Dito.
  869.     mov     ax,(lsb)                ;Load current value.
  870.     mov     bx,(lsb3)               ;Get msb number to compare.
  871.     sub     ax,bx                   ;Subtract low order portion.
  872.     mov     ax,(msb)                ;Load current value.
  873.     mov     bx,(msb3)               ;Get lsb number to compare.
  874.     sbb     ax,bx                   ;Compare it.
  875.     pop     bx                      ;Restore scratch.
  876.     pop     ax                      ;Restore scratch.
  877.     ret
  878.        
  879. ;----------------------------------
  880. ; 32Bit addition routine:
  881. ; msb lsb 32 bit number and answer. 
  882. ; msb1/lsb1 32 bit number to add.
  883. ;----------------------------------
  884. add32:  push    ax                      ;Save so we can use as scratch.
  885.     push    bx                      ;Dito.
  886.     mov     ax,(lsb)                ;Load current value.
  887.     mov     bx,(lsb1)               ;Get number to add.
  888.     add     ax,bx                   ;add values.
  889.     mov     (lsb),ax                ;Save new lsb.
  890.     mov     ax,(msb)                ;Load current msb.
  891.     mov     bx,(msb1)               ;Get number to add.
  892.     adc     ax,bx                   ;add values + carry bit.
  893.     mov     (msb),ax                ;Save new msb.
  894.     pop     bx                      ;Restore scratch.
  895.     pop     ax                      ;Restore scratch.
  896.     ret                             ;Return to caller.
  897.  
  898. ;-----------------------------------------
  899. ; 32Bit subtraction routine:  
  900. ; msb/lsb 32 Bit number to be sub from.                                          
  901. ; msb1/lsb 32 Bit number to subtract with.
  902. ;-----------------------------------------
  903. sub32:  push    ax                      ;Save so we can use as scratch.
  904.     push    bx                      ;Dito.
  905.     mov     ax,(lsb)                ;Load current value.
  906.     mov     bx,(lsb1)               ;Get number to subtract.
  907.     sub     ax,bx                   ;subtract values.
  908.     mov     (lsb),ax                ;Save new lsb.
  909.     mov     ax,(msb)                ;Load current msb.
  910.     mov     bx,(msb1)               ;Get number to add.
  911.     sbb     ax,bx                   ;sub values with borrow bit.
  912.     mov     (msb),ax                ;Save new msb.
  913.     pop     bx                      ;Restore scratch register.
  914.     pop     ax                      ;Dito.
  915.     ret                             ;Return to caller.
  916.  
  917. ;--------------------------------
  918. ; 32Bit Multiplication routine:
  919. ; msb/lsb Number to multiply.
  920. ; msb1/lsb1 Times its multiplied.
  921. ;--------------------------------
  922. mul32:  push    ax                      ;Save so we can use as scratch.
  923.     push    bx                      ;Dito.
  924.     push    cx
  925.  
  926.     pop     cx
  927.     pop     bx                      ;Restore scratch registers.
  928.     pop     ax
  929.     ret                             ;Return to caller.
  930.  
  931.     ret                             ;Return to caller.
  932.  
  933. ;--------------------------------
  934. ; All rights reserved.          -
  935. ; Dover Research Corporation    -
  936. ; 1979,1994                     -
  937. ;--------------------------------
  938. ; 32 Bit division routine       -
  939. ;--------------------------------               
  940. ;            Answer             -
  941. ;          __________           -
  942. ;   Divisor) Dividend           -
  943. ;                               -
  944. ;--------------------------------
  945. ;--------------------------------
  946. ; Divide two 32Bit integers.    -
  947. ; dvmsb/dvlsb Dividend.         -
  948. ; dmsb/dlsb Divider.            -
  949. ;                               -
  950. ; Answer in amsb/alsb.          -
  951. ; Remainder in rmsb/rlsb.       -
  952. ;--------------------------------
  953. div32:  push    ax                      ;Save scratch registers.
  954.     push    bx
  955.     push    dx
  956.     push    si
  957.  
  958. ;-------------------------
  959. ; Test for 32/16 Bit math?
  960. ;-------------------------
  961.     mov     ax,(dmsb)               ;Read upper word.
  962.     or      ax,ax                   ;test upper word for zero.
  963.     jnz     IsLong                  ;Jump if 32 bit value.
  964.  
  965. ;------------------------------
  966. ; Divide 32bit by 16 bit value.
  967. ;------------------------------
  968.     mov     cx,(dlsb)               ;Call this routine when we can.
  969.     mov     ax,(dvmsb)              ;It saves lots of stupid looping.
  970.     xor     dx,dx                              
  971.     div     cx
  972.     mov     bx,ax
  973.     mov     ax,(dvlsb)
  974.     div     cx
  975.     mov     (amsb),bx               
  976.     mov     (alsb),ax               
  977.  
  978. ;------------------------------
  979. ; Calculate 32/16Bit remainder 
  980. ; If not needed jump to byebye.
  981. ;------------------------------                                             
  982.     mov     ax,(dlsb)               ;Load divisor lsb (no msb in 16bit math)
  983.     mov     bx,(alsb)               ;Load lsb Divisor.
  984.     mul     bx                      ;AX * BX = DX:AX
  985.     mov     (rmsb),dx               ;Save 1st half of remainder msb.
  986.     mov     (rlsb),ax               ;Save 1st half of remainder lsb.
  987.     mov     ax,(dlsb)               ;Reload divisor lsb.
  988.     mov     bx,(amsb)               ;Load msb Divisor.
  989.     mul     bx                      ;AX * BX = DX:AX
  990.     add     (rmsb),ax               ;Add 2nd half of remainder.
  991.     
  992. ;---------------------------------
  993. ; Subtract to determine remainder.
  994. ;---------------------------------
  995.     mov     ax,(dvlsb)              ;Dividend.
  996.     mov     bx,(rlsb)               ;Total.
  997.     sub     ax,bx
  998.     mov     (rlsb),ax               ;Store remainder lsb.
  999.     mov     ax,(dvmsb)              ;Answer msb.                        
  1000.     mov     bx,(rmsb)
  1001.     sbb     ax,bx                   ;Sub values with borrow bit.
  1002.     mov     (rmsb),ax               ;Save remainder msb.
  1003.     jmp     byebye 
  1004.  
  1005.  
  1006. ;-----------------------------
  1007. ; Divide 32bit by 32bit value.
  1008. ;-----------------------------
  1009. IsLong: mov     cx,ax
  1010.     mov     bx,(dlsb)
  1011.     mov     dx,(dvmsb)
  1012.     mov     ax,(dvlsb)
  1013.  
  1014. ;-------------------------
  1015. ; Division by powers of 2.
  1016. ;-------------------------
  1017. ShiftLoop:      
  1018.     shr     cx,1
  1019.     rcr     bx,1
  1020.     shr     dx,1
  1021.     rcr     ax,1
  1022.     or      cx,cx
  1023.     jnz     ShiftLoop
  1024.     div     bx                      ;Answer in ax.
  1025.     mov     si,ax
  1026.     mul     (dmsb)
  1027.     xchg    ax,cx
  1028.     mov     ax,(dlsb)
  1029.     mul     si
  1030.     add     dx,cx
  1031.     jc      IsCarry
  1032.     cmp     dx,(dvmsb)
  1033.     jnbe    IsCarry
  1034.     jc      IsNull
  1035.     cmp     ax,(dvlsb)
  1036.     jbe     IsNull
  1037.  
  1038. IsCarry:dec     si
  1039.  
  1040. IsNull: xor     dx,dx
  1041.     xchg    ax,si
  1042.     mov     (amsb),0
  1043.     mov     (alsb),ax
  1044.     
  1045. ;------------------------------
  1046. ; Calculate 32/32Bit remainder 
  1047. ; If not needed jump to byebye.
  1048. ;------------------------------                                             
  1049.     mov     ax,(dlsb)               ;Load Divisor lsb.
  1050.     mov     bx,(alsb)               ;Load lsb answer.       
  1051.     mul     bx                      ;AX * BX = DX:AX
  1052.     mov     (rmsb),dx               ;Save 1st half of remainder msb.
  1053.     mov     (rlsb),ax               ;Save 1st half of remainder lsb.
  1054.     mov     ax,(dmsb)
  1055.     mov     bx,(alsb)               ;Answer in 32Bit div is always just lsb.
  1056.     mul     bx                      ;AX * BX = DX:AX
  1057.     add     (rmsb),ax               ;Add 2nd half of remainder.
  1058.  
  1059. ;---------------------------------
  1060. ; Subtract to determine remainder.
  1061. ;---------------------------------
  1062.     mov     ax,(dvlsb)
  1063.     mov     bx,(rlsb)
  1064.     sub     ax,bx
  1065.     mov     (rlsb),ax               ;Store remainder lsb.
  1066.     mov     ax,(dvmsb)
  1067.     mov     bx,(rmsb)
  1068.     sbb     ax,bx                   ;Sub values with borrow bit.
  1069.     mov     (rmsb),ax               ;Save remainder msb.
  1070.  
  1071. byebye: pop     si
  1072.     pop     dx
  1073.     pop     bx
  1074.     pop     ax
  1075.     ret
  1076.  
  1077. ;---------------------------------------------
  1078. ; DISPLAY CURRENT FREQUENCY.            
  1079. ; Step = lsb1/msb1
  1080. ; VFO = lsb/msb
  1081. ; 5.05MHz = vfomsb/vfolsb (in binary DDS talk)
  1082. ;---------------------------------------------
  1083. grok    db      'display freq'
  1084.  
  1085. disfrq: push    ax
  1086.     push    bx
  1087.     push    cx
  1088.     push    dx
  1089.     mov     dx,OFFSET msg12b
  1090.     call    print                   ;Clear status line and home cursor.
  1091.     mov     dx,OFFSET msg14
  1092.     call    print
  1093.     mov     (msb5),(msb1)           ;Save step freq.
  1094.     mov     (lsb5),(lsb1)
  1095.     mov     (msb4),(msb)            ;Save current VFO frequency.
  1096.     mov     (lsb4),(lsb)
  1097.  
  1098.     mov     cx,0                    ;Clear cx
  1099.     mov     (msb1),vfomsb           ;load 5.05 MHz freq.
  1100.     mov     (lsb1),vfolsb
  1101.     call    sub32                   ;msb/lsb = freq (not freq + 5.05 MC)
  1102.  
  1103.     mov     (dvmsb),(msb)           ;Load current VFO freq + 5.05 to Dividend.
  1104.     mov     (dvlsb),(lsb)
  1105.     mov     (dmsb),h100km           ;Load divisor with 100Khz value.
  1106.     mov     (dlsb),h100kl
  1107.     call    div32                   ;How many 100Khzs do we have?
  1108.     mov     cx,(alsb)
  1109.     call    pnum                    ;Show first number on display.
  1110.        
  1111.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1112.     mov     (dvlsb),(rlsb)
  1113.     mov     (dmsb),h10km            ;Get 10Khz value.
  1114.     mov     (dlsb),h10kl
  1115.     call    div32                   ;How many 10Khzs do we have?
  1116.     mov     cx,(alsb)
  1117.     call    pnum                    ;Show second number on display.
  1118.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1119.     mov     (lsb),(rlsb)
  1120.  
  1121.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1122.     mov     (dvlsb),(rlsb)
  1123.     mov     (dmsb),h1km             ;Load 1 Khz value.
  1124.     mov     (dlsb),h1kl
  1125.     call    div32                   ;How many 1Khzs do we have?
  1126.     mov     cx,(alsb)
  1127.     call    pnum                    ;Show third number.
  1128.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1129.     mov     (lsb),(rlsb)
  1130.  
  1131.     mov     dx,OFFSET mdot          ;Load period.
  1132.     call    print                   ;and print it now.
  1133.  
  1134.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1135.     mov     (dvlsb),(rlsb)
  1136.     mov     (dmsb),0                ;Msb is zero for these values.
  1137.     mov     (dlsb),h100             ;load 100 Hz value.
  1138.     call    div32                   ;how many 100 hzs do we have?
  1139.     mov     cx,(alsb)
  1140.     call    pnum                    ;Print fourth number.
  1141.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1142.     mov     (lsb),(rlsb)
  1143.  
  1144.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1145.     mov     (dvlsb),(rlsb)
  1146.     mov     (dmsb),0
  1147.     mov     (dlsb),h10              ;load 10 Hz value.
  1148.     call    div32                   ;How many 10 Hzs do we have?
  1149.     mov     cx,(alsb)
  1150.     call    pnum                    ;print fifth number.
  1151.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1152.     mov     (lsb),(rlsb)
  1153.  
  1154.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1155.     mov     (dvlsb),(rlsb)
  1156.     mov     (dmsb),0
  1157.     mov     (dlsb),h1               ;load 1 hz value.
  1158.     call    div32                   ;how many 1 hzs do we have?
  1159.     mov     cx,(alsb)
  1160.     call    pnum                    ;print sixth number.
  1161.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1162.     mov     (lsb),(rlsb)            
  1163.  
  1164.     mov     dx,OFFSET mdot          ;Load period...
  1165.     call    print                   ;and print it.
  1166.     mov     (dvmsb),(rmsb)          ;use remainder for next calculation.
  1167.     mov     (dvlsb),(rlsb)
  1168.     mov     (dlsb),h01              ;load 0.1 hz value.
  1169.     call    div32                   ;How many 0.1 hzs do we have left?
  1170.     mov     cx,(alsb)
  1171.     call    pnum                    ;Print em!
  1172.     mov     (msb),(rmsb)            ;use remainder for next calculation.
  1173.     mov     (lsb),(rlsb)
  1174.  
  1175.     mov     dx,OFFSET crlf          ;home cursor.  msg15
  1176.     call    print
  1177.  
  1178. ;----------------------------------------------------
  1179. ; Done printing frequency so restore all the goodies.
  1180. ;----------------------------------------------------
  1181.     mov     (msb1),(msb5)           ;Restore step freq.
  1182.     mov     (lsb1),(lsb5)
  1183.     mov     (msb),(msb4)            ;Restore current VFO frequency.
  1184.     mov     (lsb),(lsb4)
  1185.     pop     dx                      ;Restore work registers.
  1186.     pop     cx      
  1187.     pop     bx
  1188.     pop     ax
  1189.     ret                             ;Return to caller.
  1190.  
  1191.  
  1192.  
  1193.  
  1194. ;------------------------------
  1195. ; PRINT A NUMBER (Binary-ASCII)
  1196. ; My crude way to take a 
  1197. ; binary number and print it.
  1198. ;------------------------------
  1199. pnum:   nop
  1200.     nop
  1201.     nop
  1202.     cmp     cl,10                   ;Weird roll off test.
  1203.     jne     norm                    ;0,1,2,3,4,5,6,7,8,10.
  1204.     dec     cl                      ;It IS weird so make it normal.
  1205. norm:   add     cl,30h                  ;Convert to ascii.
  1206.     mov     dl,cl
  1207.     mov     ah,06h
  1208.     int     21h                     ;Direct console output.  
  1209.     mov     cx,0
  1210.     ret
  1211.  
  1212.  
  1213.  
  1214. ;---------------------------------------------
  1215. ; KEYBOARD I/O
  1216. ;---------------------------------------------
  1217. keyin:  mov     ah,10h
  1218.     int     16h
  1219.     ret                             ;Return to caller.
  1220.                              
  1221. ;---------------------------------------------
  1222. ; PRINT:
  1223. ; DX Contains the offset to the $ terminated 
  1224. ;    text string to be printed to the screen. 
  1225. ;---------------------------------------------   
  1226. print:  push    ax
  1227.     mov     ah,9
  1228.     int     21h
  1229.     pop     ax
  1230.     ret                     ;Return to caller.
  1231.  
  1232. ;---------------------------------------------
  1233. ; CLEAR THE SCREEN
  1234. ;---------------------------------------------
  1235. cls:    push    ax
  1236.     push    bx
  1237.     push    cx
  1238.     push    dx
  1239.     mov     ah,6            ;Scroll up funtion
  1240.     mov     al,0            ;code to blank screen.
  1241.     mov     ch,0            ;upper left row.
  1242.     mov     cl,0            ;Upper left column.
  1243.     mov     dh,50           ;Lower right row.
  1244.     mov     dl,79           ;Lower right column
  1245.     mov     bh,7            ;Blank line attribute.
  1246.     int     10h             ;Call video rom.
  1247.     pop     dx
  1248.     pop     cx
  1249.     pop     bx
  1250.     pop     ax
  1251.     ret
  1252.  
  1253. ;---------------------------------------------
  1254. ; BEEP: SOUNDS THE ERROR TONE ON THE SPEAKER.
  1255. ;---------------------------------------------
  1256. beep:   push    ax
  1257.     push    bx
  1258.     push    cx
  1259.     push    dx        
  1260.     cli                          ;no interrupts
  1261.     mov     si,2                 ;do hole thing twice
  1262. agin1:  mov     bp,20                ;we want 20 cycles of sound
  1263.     mov     al,10110110xb        ;must address channel 2
  1264.     out     43h,al               ;mode 3 - send it
  1265.     mov     bx,100               ;start frequency very high
  1266. agin2:  mov     ax,bx                ;place in (ax)
  1267.     out     42h,al               ;send LSB
  1268.     mov     al,ah                ;move MSB into (al)
  1269.     out     42h,al               ;send it to port
  1270.     in      al,61h               ;get value from speaker port
  1271.     or      al,00000011xb        ;ORing turns speaker on
  1272.     out     61h,al               ;send it
  1273.     mov     cx,30000             ;our delay count 
  1274. looperq:loop    looperq              ;do nothing loop so we can hear sound
  1275.     add     bx,50                ;lower frequency a bit for next pass
  1276.     in      al,61h               ;get value from port
  1277.     and     al,11111100xb        ;ANDing turns speaker off 
  1278.     out     61h,al               ;send it
  1279.     dec     bp                   ;decrement cycle count
  1280.     jnz     agin2                ;if not = 0 do again
  1281.     dec     si                   ;else decrement repeat count
  1282.     jnz     agin1                ;if not = 0 do hole thing again
  1283.     sti                          ;else turn interrupts back on
  1284.     pop     dx
  1285.     pop     cx
  1286.     pop     bx
  1287.     pop     ax
  1288.     ret
  1289.                             
  1290. ;───────────────────────────────────────────────────────────────
  1291. ;    I/O DELAY
  1292. ;       Delay to ensure successive I/O operations to the same 
  1293. ;       device are not too fast on a fast CPU.  First time 
  1294. ;       iodelay is called, a 5 mS delay occurs to calibrate
  1295. ;       the delay loop.
  1296. ;
  1297. ;       Called with:    nothing
  1298. ;
  1299. ;       Returns:        delay of 1 to 16 uS
  1300. ;
  1301. ;       Regs used:      none (flags altered)
  1302.  
  1303. iodelay:push    cx                      ;Save count register.
  1304.     mov     cx, cs:[io_count]       ;Read our count...
  1305.     jcxz    io_init                 ;Is it set?
  1306.  
  1307. io_delay_loop:
  1308.     loop    io_delay_loop      ; 13 cycles per loop on a 386
  1309.     pop     cx
  1310.     ret
  1311.  
  1312. ; first time run, so determine initialization value and save
  1313.  
  1314. io_init:
  1315.     push    ax                      ;Save registers.
  1316.     push    bx
  1317.     push    dx
  1318.     push    es
  1319.  
  1320.     mov     ax, cs
  1321.     mov     es, ax
  1322.     mov     ax, 8300h               ; set wait interval
  1323.     mov     cx, 0
  1324.     mov     dx, 5000                ; delay 5 mS, util wait flag
  1325.     mov     bx, offset io_flag      ;  is set
  1326.     int     15h                     ; start 5 mS delay
  1327.     jc      io_failed_15            ; unimplemented or in progress
  1328.  
  1329. ; the RTC timer has begun, and will set bit 7 of the wait flag when
  1330. ; 5 mS elapses.  Meanwhile, the software loop counts down slowly for
  1331. ; slow systems, and fast for fast systems.  The loop is 30 cycles 
  1332. ; on a 386 CPU.  Other CPUs will vary slightly from this.
  1333.  
  1334.     dec     cx                      ; cx = FFFFh
  1335.  
  1336. io_delay_loop2:
  1337.     test    cs:[io_flag],45         ; flag set after 5 mS
  1338.     jnz     io_5ms_done             ; jump if 5 ms complete
  1339.     jmp     short $+2
  1340.     loop    io_delay_loop2
  1341.  
  1342.     mov     ax, 100                 ; gets here if > 400 Mhz CPU,
  1343.     jmp     io_exit                 ;  so use really large number
  1344.  
  1345. ; cx = countdown from FFFF 
  1346.  
  1347. io_5ms_done:
  1348.     mov     ax, 0FFFFh
  1349.     sub     ax, cx                  ; get number of times looped
  1350.     mov     bx, 1500                ; adjustment factor
  1351.     xor     dx, dx                  ; dx zeroed for divde
  1352.     div     bx                      ; ax= dx:ax/cx
  1353.     cmp     ax, 0
  1354.     je      io_1_delay              ; set at least 1 delay
  1355.     jmp     io_set                  ; ax = delay value
  1356.  
  1357. io_failed_15:
  1358.     or      ah, ah                  ; was int 15 supported or busy?
  1359.     jz      io_exit                 ; jump if busy, try again later
  1360.                     ; only slow machines fail int 15h
  1361. io_1_delay:
  1362.     mov     ax, 1                   ; mininum delay period
  1363. io_set:
  1364.     mov     cs:[io_count], ax       ; load delay value
  1365. io_exit:
  1366.     pop     es
  1367.     pop     dx
  1368.     pop     bx
  1369.     pop     ax
  1370.     pop     cx
  1371.     ret
  1372.  
  1373. crlf:   db      13   
  1374.     db      "$"
  1375.  
  1376. cmsg:   db      "* * * * * * * * * * * * * * *",13,10
  1377.     db      "*    DOVER DIGITAL VFO      *",13,10
  1378.     db      "* COPYRIGHT DOVER RESEARCH  *",13,10
  1379.     db      "*   All rights reserved     *",13,10
  1380.     db      "*      (612)492-3913        *",13,10
  1381.     db      "*     by Jay Craswell       *",13,10 
  1382.     db      "*     WB0VNE / AAV5TH       *",13,10
  1383.     db      "*    NOT PUBLIC DOMAIN      *",13,10
  1384.     db      "* * * * * * * * * * * * * * *",13,10,10
  1385.     db      "$"
  1386.  
  1387. savemsg:db      "Press an F Key to store this frequency.         ",13
  1388.     db      "$"
  1389.  
  1390. msg:    db      "* * * * * * * * * * * * * * *",13,10
  1391.     db      "*     DOVER DIGITAL VFO     *",13,10
  1392.     db      "* <<<<<<<< Rev 1.4 >>>>>>>> *",13,10
  1393.     db      "* 5.5 MHz to 6.0 MHz Version*",13,10
  1394.     db      "* * * * * * * * * * * * * * *",13,10
  1395.     db      "$" 
  1396.  
  1397. msg0:   db      "(d)irect keyboard entry.",13,10
  1398.     db      "(p)anadaptor (with option).",13,10
  1399.     db      "(r)eset VFO to zero.",13,10
  1400.     db      "(s)ave a freq to a memory key.",13,10
  1401.     db      "(b)and edges & Panadaptor step.",13,10
  1402.     db      "(?) About DigiVFO.",13,10
  1403.     db      "(+) Raise VFO steps.",13,10
  1404.     db      "(-) Lower VFO steps.",13,10
  1405.     db      "Up Arrow (shiftable) freq up.",13,10
  1406.     db      "Dn Arrow (shiftable) freq dn.",13,10
  1407.     db      "ESC quits to DOS",13,10,10
  1408.     db      "----------------------------------------"
  1409.     db      "----------------------------------------",13,10
  1410.     db      "$"
  1411.  
  1412. msg1:   db      "Program ends                                    ",13
  1413.     db      "$"
  1414.  
  1415. msg2:   db      "                                       0.009 / 0.1 Hertz steps",13
  1416.     db      "$"
  1417.  
  1418. msg3:   db      "                                       0.1 / 1 Hertz steps           ",13
  1419.     db      "$"
  1420.  
  1421. msg4:   db      "                                       1 / 10 Herts steps            ",13
  1422.     db      "$"
  1423.  
  1424. msg5:   db      "                                       10 / 100 Hertz steps          ",13
  1425.     db      "$"
  1426.  
  1427. msg6:   db      "                                       100Hertz / 1KHz steps         ",13
  1428.     db      "$"
  1429.  
  1430. msg7:   db      "                                       1 / 10KHz steps               ",13
  1431.     db      "$"
  1432.  
  1433. msg8:   db      "                                       10KHz / 100KHz steps          ",13
  1434.     db      "$"
  1435.  
  1436. msg9:   db      "                                       100KHz / 1Mc steps            ",13
  1437.     db      "$"
  1438.  
  1439. msg10:  db      "Sorry not in this version             ",13
  1440.     db      "$"
  1441.  
  1442. msg11:  db      "Memory stored..                       ",13
  1443.     db      "$"
  1444.  
  1445. msg12:  db      "Enter "
  1446.     db      "xx."
  1447.     db      "$"
  1448.  
  1449. msg12b: db      "                                      ",13
  1450.     db      "$"
  1451.  
  1452. msg14:  db      "Freq: xx."
  1453.     db      "$"
  1454.  
  1455. msg15   db      " |",13
  1456.  
  1457. mdot:   db      "."
  1458.     db      "$"
  1459.  
  1460. badkey: db      "Not a valid choice.                   ",13
  1461.     db      "$"
  1462.  
  1463. msgli:  db      "Loading it!                           ",13   
  1464.     db      "$"
  1465.  
  1466. mn0:    db      "0"
  1467.     db      "$"
  1468.  
  1469. mn1:    db      "1"
  1470.     db      "$"
  1471.  
  1472. mn2:    db      "2"
  1473.     db      "$"
  1474.  
  1475. mn3:    db      "3"
  1476.     db      "$"
  1477.  
  1478. mn4:    db      "4"
  1479.     db      "$"
  1480.  
  1481. mn5:    db      "5"
  1482.     db      "$"
  1483.  
  1484. mn6:    db      "6"
  1485.     db      "$"
  1486.  
  1487. mn7:    db      "7"
  1488.     db      "$"
  1489.  
  1490. mn8:    db      "8"
  1491.     db      "$"
  1492.  
  1493. mn9:    db      "9"
  1494.     db      "$"
  1495.  
  1496. code    ends               
  1497.                                                        
  1498.